// app/rfq/page.tsx import * as React from "react"; import { Metadata } from "next"; import { type SearchParams } from "@/types/table"; import { Shell } from "@/components/shell"; import { DataTableSkeleton } from "@/components/data-table/data-table-skeleton"; import { HelpCircle, Package, FileText, ClipboardList, Layers } from "lucide-react"; import { Tabs, TabsContent, TabsList, TabsTrigger, } from "@/components/ui/tabs"; import { Popover, PopoverContent, PopoverTrigger, } from "@/components/ui/popover"; import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; import { RfqTable } from "@/lib/rfq-last/table/rfq-table"; import { getRfqs } from "@/lib/rfq-last/service"; import { searchParamsRfqCache } from "@/lib/rfq-last/validations"; import { InformationButton } from "@/components/information/information-button"; import { useTranslation } from "@/i18n" export const metadata: Metadata = { title: "RFQ 관리", description: "RFQ 견적 요청 관리 시스템", }; interface RfqPageProps { params: Promise<{lng: string}> searchParams: Promise; } // 탭별 데이터 카운트를 가져오는 함수 async function getTabCounts() { try { const [generalData, preBiddingData, itbData, rfqData] = await Promise.all([ getRfqs({ page: 1, perPage: 1, sort: [], filters: [], joinOperator: "and", search: "", rfqCategory: "general" }), getRfqs({ page: 1, perPage: 1, sort: [], filters: [], joinOperator: "and", search: "", rfqCategory: "pre_bidding" }), getRfqs({ page: 1, perPage: 1, sort: [], filters: [], joinOperator: "and", search: "", rfqCategory: "itb" }), getRfqs({ page: 1, perPage: 1, sort: [], filters: [], joinOperator: "and", search: "", rfqCategory: "rfq" }), ]); return { general: generalData.total || 0, pre_bidding: preBiddingData.total || 0, itb: itbData.total || 0, rfq: rfqData?.total || 0, }; } catch (error) { console.error("Error fetching tab counts:", error); return { general: 0, pre_bidding: 0, itb: 0, rfq: 0, }; } } export default async function RfqPage(props: RfqPageProps) { const searchParams = await props.searchParams; const {lng} = await props.params const {t} = await useTranslation(lng, 'menu') // nuqs 기반 파라미터 파싱 const search = searchParamsRfqCache.parse(searchParams); // 탭별 데이터 카운트 가져오기 const tabCounts = await getTabCounts(); console.log(search.rfqCategory ,"search.rfqCategory ") // 현재 선택된 탭 (URL 파라미터에서 가져오거나 기본값 'all') const currentTab = search.rfqCategory || "itb"; // 각 탭별로 데이터 프리패칭 // const allData = await getRfqs({ ...search, rfqCategory: "all" }); const generalData = await getRfqs({ ...search, rfqCategory: "general" }); const preBiddingData = await getRfqs({ ...search, rfqCategory: "pre_bidding" }); const itbData = await getRfqs({ ...search, rfqCategory: "itb" }); const rfqData = await getRfqs({ ...search, rfqCategory: "rfq" }); return ( {/* 헤더 */}

{t('menu.procurement.budget_rfq')}

{/* 탭 컨테이너 */} ITB {tabCounts.itb > 0 && ( {tabCounts.itb} )} RFQ {tabCounts.rfq > 0 && ( {tabCounts.rfq} )} 일반견적 {tabCounts.general > 0 && ( {tabCounts.general} )} 사전견적(입찰) {tabCounts.pre_bidding > 0 && ( {tabCounts.pre_bidding} )} {/* 일반견적 탭 */} } > {/* 사전견적(입찰) 탭 */} } > {/* ITB 탭 */} } > {/* RFQ(PR) 탭 */} } >
); }